IF (ENABLE_COVERAGE)
    SET(CMAKE_CXX_FLAGS "-g -Wall -O0 -fPIC -DMUDUO_STD_STRING -DHAVE_NETINET_IN_H -DGTEST")
ELSE ()
    SET(CMAKE_CXX_FLAGS "-g -Wall -O2 -fPIC -DMUDUO_STD_STRING -DHAVE_NETINET_IN_H -DGTEST")
ENDIF ()
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
MESSAGE(STATUS "CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}")

enable_testing()

IF (ENABLE_COVERAGE)
    include(CodeCoverage)
    APPEND_COVERAGE_COMPILER_FLAGS()
ENDIF ()
MESSAGE(STATUS "CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")

option(MNS_SDK_DOWNLOAD_GTEST "Download and build a fresh copy of googletest.
Requires Internet access." ON)
set(MNS_SDK_SYSTEM_GTEST_SOURCE_DIR "" CACHE PATH "System googletest source
directory.")

if (MNS_SDK_DOWNLOAD_GTEST)
    include(SetupGtest)
elseif (MNS_SDK_SYSTEM_GTEST_SOURCE_DIR)
    add_subdirectory("${MNS_SDK_SYSTEM_GTEST_SOURCE_DIR}" "${PROJECT_BINARY_DIR}/system-googletest-build")
else ()
    message(FATAL_ERROR "Googletest is not available")
endif ()

INCLUDE_DIRECTORIES(SYSTEM ${GTEST_INCLUDE_DIR})
INCLUDE_DIRECTORIES(SYSTEM ${INCLUDE_ECHO_OUTPUT_PATH})

SET(SYSTEM_INCLUDE_PATH /usr/include/)
INCLUDE_DIRECTORIES(SYSTEM ${SYSTEM_INCLUDE_PATH})
INCLUDE_DIRECTORIES(SYSTEM ${SYSTEM_INCLUDE_PATH}/thrift)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})

INCLUDE_DIRECTORIES(SYSTEM ${INCLUDE_OUTPUT_PATH})
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})

ADD_EXECUTABLE(mns_thread_test mns_thread_test.cc)
TARGET_LINK_LIBRARIES(mns_thread_test -Xlinker "-(" libmns_sdk.a
        ${MUDUO_BASE_LIBRARY} ${MUDUO_NET_LIBRARY} ${MUDUO_HTTP_LIBRARY}
        pthread rt  uuid ${ZLIB_LIBRARY} ${LOG4CPLUS_LIBRARY}
        liboctoidl.a ${THRIFT_LIBRARY} gtest -Xlinker "-)")
